package org.glut.backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.glut.backend.service.IStreetFoodService;
import org.glut.backend.domain.StreetFood;
import org.glut.backend.mapper.StreetFoodMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 小吃表 服务实现类
 *
 * @author xiuci1412
 * @since 2025-08-01 17:43
 */
@Service
public class StreetFoodServiceImpl extends ServiceImpl<StreetFoodMapper, StreetFood> implements IStreetFoodService {

    @Override
    public Map<Integer, List<StreetFood>> getList(Integer cinemaId) {
        LambdaQueryWrapper<StreetFood> streetFoodLambdaQueryWrapper = new LambdaQueryWrapper<>();
        streetFoodLambdaQueryWrapper.eq(StreetFood::getCinemaId,cinemaId);
        List<StreetFood> streetFoods = baseMapper.selectList(streetFoodLambdaQueryWrapper);
        Map<Integer, List<StreetFood>> streamFoodList = streetFoods.stream()
                .collect(Collectors.groupingBy(StreetFood::getType));
        return streamFoodList;
    }
}